package org.im.service.message.exp;

import org.im.service.message.bean.rs.ErrMessageType;

public class MessageException extends Exception {

	private static final long serialVersionUID = -2023172208434889639L;

	private boolean isOk;
	
	private int errorCode;
	
	private String errorMessage;
	
	public static MessageException ok() {
		MessageException mr = new MessageException();
		mr.setOk(true);
		return mr;
	}
	
	public static MessageException error(ErrMessageType type) {
		MessageException mr = new MessageException();
		mr.setOk(false);
		mr.setErrorCode(type.getCode());
		mr.setErrorMessage(type.getMsg());
		return mr;
	}

	public boolean isOk() {
		return isOk;
	}

	public void setOk(boolean isOk) {
		this.isOk = isOk;
	}

	public int getErrorCode() {
		return errorCode;
	}

	public void setErrorCode(int errorCode) {
		this.errorCode = errorCode;
	}

	public String getErrorMessage() {
		return errorMessage;
	}

	public void setErrorMessage(String errorMessage) {
		this.errorMessage = errorMessage;
	}
	
}
